home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 41
/
Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso
/
Aminet
/
gfx
/
edit
/
AmiCAD_2.07.lha
/
AmiCAD
/
ARexx
/
ChargeRC.AmiCAD
< prev
next >
Wrap
Text File
|
2000-11-04
|
4KB
|
169 lines
/* Tracé de la courbe de charge d'un condensateur.
Version 1.00: 12 novembre 1998
Version 1.01: 13 avril 2000 (modif SAVEALL)
Version 1.02: 4 novembre 2000 (localisation anglais/français)
$VER: 1.01 (© R.Florac, 13 Avril 2000) */
options results /* indispensable pour récupérer le résultat des macros */
signal on error /* pour l'interception des erreurs */
signal on syntax
'LANGUAGE'
if result='français.language' then fr=1
else fr=0
clip=-1
FIRSTSEL; obj=result
if obj>0 then do
'TYPE(FIRSTSEL)'; type=result
if type=22 then do
'CLIPUNIT(5)'; clip=result
'COORDS(FIRSTSEL)'; coords=result
PARSE VAR coords x0 ',' y0 ',' x1 ',' y1
xg=minima(x0,x1); xd=maxima(x0,x1)
yh=minima(y0,y1); yb=maxima(y0,y1)
l=xd-xg+1; h=yb-yh+1
'NEXTSEL('obj')'; obj=result
end
end
else obj=1
if obj>0 then do
if fr=1 then 'MESSAGE("Dessinez et sélectionnez"+CHR(10)+"un rectangle dans"+CHR(10)+"lequel doit être"+CHR(10)+"intégrée la grille")'
else 'MESSAGE("Draw and select the box"+CHR(10)+"where the grid will be placed"+CHR(10)+"before calling this script")'
call quitter
end
ndh=5
y1=yh+h
x1=xg+ndh*(l%ndh)
'SAVEALL'
'DELETE(FIRSTSEL):ROTATE(0,0)'
/* Tracé des lignes verticales */
do i=1 to 5
x2 = xg+i*(l/ndh)
x2 = x2%1
'DRAWMODE(1)'
do c=1 to 9
xc = x2-(l/ndh)/10*c
xc=xc%1
'DRAW('xc','yh','xc','yb')'
end
'DRAWMODE(2):DRAW('x2','yh','x2','yb')'
end
/* Repères verticaux */
if h>300 then hc=2
else hc=1
if l>600 then lc=2
else lc=1
'SETSCALE(0,'lc'*100,'hc'*100)'
if lc=1 then lc=8
else lc=16
if hc=1 then hc=8
else hc=16
if xg-5*lc<0 then do
if fr=1 then 'MESSAGE("Position grille incorrecte"+CHR(10)+"(Trop à gauche)")'
else 'MESSAGE("Bad grid placement"+CHR(10)+"(too left)")'
call quitter
end
'DRAWMODE(1):WRITE("0",'xg-lc-lc','yb+hc/2')'
p=h%4
'WRITE("0,25",'xg-4*lc-lc','yh+3*p+hc/2')'
'WRITE("0,5",'xg-3*lc-lc','yh+2*p+hc/2')'
'WRITE("0,75",'xg-4*lc-lc','yh+p+hc/2')'
'WRITE("1",'xg-lc-lc','yh+hc/2')'
/* Tracé des lignes horizontales */
ndv=2
do i=1 to ndv
y2 = yh+(i-1)*(h/ndv)
y2=y2%1
'DRAWMODE(2):DRAW('xg','y2','xd','y2')'
y2 = (yh)+i*(h/ndv)
y2 = y2%1
'DRAWMODE(1)'
do c=1 to 9
yc = y2-(h/ndv)/10*c
yc=yc%1
'DRAW('xg','yc','xd','yc')'
end
end
/* Repères horizontaux */
n=0.5
p=(l/10)%1
ndv=yb+hc+hc/2
'WRITE("0",'xg-lc/2','ndv')'
'WRITE("0,5",'xg+p-lc','ndv')'
'WRITE("1RC",'xg+2*p-2*lc+lc/2','ndv')'
'WRITE("1,5",'xg+3*p-2*lc+lc/2','ndv')'
'WRITE("2RC",'xg+4*p-2*lc+lc/2','ndv')'
'WRITE("2,5",'xg+5*p-2*lc+lc/2','ndv')'
'WRITE("3RC",'xg+6*p-2*lc+lc/2','ndv')'
'WRITE("3,5",'xg+7*p-2*lc+lc/2','ndv')'
'WRITE("4RC",'xg+8*p-2*lc+lc/2','ndv')'
'WRITE("4,5",'xg+9*p-2*lc+lc/2','ndv')'
'WRITE("5RC",'xg+10*p-2*lc+lc/2','ndv')'
/* Tracé des axes */
'WRITE("U",'xg-lc*2','yh-hc')'
'WRITE("t",'xd+3*lc','ndv')'
'SETSCALE(0,100,100):DRAWMODE(2):DRAW('xg','yb','xg','yh-hc'):DRAW('xg','yb','xd+2*lc','yb')'
'CONVERT(PUTPART("Flèche",'xg-10','yh-hc-20'),1)'
'ROTATE(0,1):CONVERT(PUTPART("Flèche",'xd+2*lc','yb-10'),1):DRAWMODE(3)'
/* Tracé de la courbe de charge */
if ~show('L','rexxmathlib.library') then
call addlib('rexxmathlib.library',0,-30)
tau=l/5
y0=yb; x0=xg
do i=1 to l/5
y=h+(-h*exp(-5*i/tau))
y=y%1
'DRAW('x0','y0','x0+5','yb-y')'
x0=x0+5
y0=yb-y
end
/* Tracé de la courbe de charge */
y0=yh; x0=xg
do i=1 to l/5
y=h+(-h*exp(-5*i/tau))
y=y%1
'DRAW('x0','y0','x0+5','yh+y')'
x0=x0+5
y0=yh+y
end
call quitter
minima: procedure
parse arg v1,v2
if v1<v2 then return v1
return v2
end
maxima: procedure
parse arg v1,v2
if v1>v2 then return v1
return v2
end
quitter: procedure expose clip
if clip>=0 then 'CLIPUNIT('clip')'
exit
/* Traitement des erreurs, interruption du programme */
syntax:
erreur=RC
if fr=1 then 'MESSAGE("Script ChargeRC.AmiCAD"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
else 'MESSAGE("Script ChargeRC.AmiCAD"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
exit
error:
if fr=1 then 'MESSAGE("Script ChargeRC.AmiCAD"+CHR(10)+"Erreur en ligne 'SIGL'")'
else 'MESSAGE("Script ChargeRC.AmiCAD"+CHR(10)+"Error in line 'SIGL'")'
exit